package com.fit.pages.arrangement;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.UserAccess;
import com.fit.dao.arrangement.ArrangementDAO;
import com.fit.entities.Arrangement;
import com.fit.pages.ErrorPage;

@AdminAccess
@UserAccess
public class AddArrangement {

	@Property
	private Arrangement arrangement;

	@InjectPage
	private ErrorPage errorPage;

	@Inject
	private ArrangementDAO arrangementDAO;

	Object onSuccess() {
		errorPage.setMessage("");

		if (arrangementDAO.save(arrangement)) {
			errorPage.setMessage("Arrangement successfully added");
			return errorPage;
		} else {
			errorPage.setMessage("Arrangement is null");
			return errorPage;

		}

	}

}
